﻿@model dynamic
<div id="sampleGrid">
</div>
<div id="sampleDialog" title="Sample Title">
    <form id="sampleForm">
    <ul>
        <li>
            <label for="field1">Field 1:</label><input type="text" id="field1" />
        </li>
        <li>
            <label for="field2">Field 2:</label><input type="text" id="field2" />
        </li>
    </ul>
    </form>
</div>
<button id="sampleDialogButton" class="button">Show Sample Dialog</button>
<input id="fileupload" type="file" name="files[]" data-url="/sample/upload" class="hidden">
<button id="selectFileButton" class="button">Select file</button>
<label id="fileUploadFilename"></label>
<button id="uploadButton" class="button">Upload</button>

@section styles
{
    <link href="@Url.Content("~/Content/css/sample.css")" rel="stylesheet" type="text/css" />
}
@section scripts
{
    <script src="@Url.Content("~/scripts/jquery.iframe-transport.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/scripts/jquery.fileupload.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/js/sample.js")" type="text/javascript"></script>
    <script>
        $(function () {
            var _data;
            $('#fileupload').fileupload({
                dataType: 'json',
                done: function (e, data) {
                    $.each(data.result, function (index, file) {
                        $('<p/>').text(file.name).appendTo(document.body);
                    });
                },
                add: function (e, data) {
                    //debugger;
                    _data = data;
                    $('#fileUploadFilename').text(data.files[0].fileName);
                    //$(this).fileupload('resize', data).done(function () {
                    //data.submit();
                    //});
                }
            });
            $('#selectFileButton').click(function () {
                $('#fileupload').click();
            });
            $('#uploadButton').click(function () {
                _data.submit();
            });
        });
    </script>
}
